﻿#pragma once
#include <string>
#include "Types.h"

using std::string;


class Tick
{
public:
	//交易日
	Int64Type TradingDay;
	//交易所代码
	ExchangeIDType ExchangeID;
	//合约代码
	InstrumentIDType InstrumentID;
	//Tick时间戳
	Int64Type UpdateTs;
	//最新价
	DecimalType LastPrice;
	//最新成交量
	DoubleType LastTraded;
	//总成交量
	DoubleType Volume;
	//持仓量
	DoubleType OpenInterest;
	//成交额
	DecimalType Turnover;
	//买一价
	DecimalType BidPrice1;
	//买一量
	DoubleType BidVolume1;
	//卖一价
	DecimalType AskPrice1;
	//卖一量
	DoubleType AskVolume1;
	//昨结算价
	DecimalType PreSettlementPrice;
	//昨收盘价
	DecimalType PreClosePrice;
	//左持仓量
	DoubleType PreOpenInterest;
	//最高成交价
	DecimalType HighestPrice;
	//最低成交价
	DecimalType LowestPrice;

public:
	static Tick* Allocate();
	void Free();
	static std::string GetHeadString();
	static std::string CreateDuckdbTableSqlString();
	static std::string CreateSqliteTableSqlString();
	static std::string CreateMysqlTableSqlString();
	
	static std::string TruncateDuckdbSqlString();
	static std::string TruncateSqliteSqlString();
	static std::string TruncateMysqlSqlString();
	int ToCsvString(char* buff) const;
	int ToDebugString(char* buff) const;
	int GetSqlString(char* buff) const;
};

class Bar
{
public:
	//交易日
	Int64Type TradingDay;
	//交易所代码
	ExchangeIDType ExchangeID;
	//合约代码
	InstrumentIDType InstrumentID;
	//Tick时间戳
	Int64Type UpdateTs;
	//Bar精度
	PreceType Prece;
	//最新成交量
	DoubleType LastTraded;
	//总成交量
	DoubleType Volume;
	//成交额
	DoubleType Turnover;
	//持仓量
	DoubleType OpenInterest;
	//Bar开盘价
	DecimalType Open;
	//Bar最高价
	DecimalType High;
	//Bar最低价
	DecimalType Low;
	//Bar收盘价
	DecimalType Close;
	//日内最高成交价
	DecimalType HighestPrice;
	//日内最低成交价
	DecimalType LowestPrice;
	//品种类型
	ProductClassType ProductClass;
	//标的合约
	InstrumentIDType UnderlyingID;

public:
	static Bar* Allocate();
	void Free();
	static std::string GetHeadString();
	static std::string CreateDuckdbTableSqlString();
	static std::string CreateSqliteTableSqlString();
	static std::string CreateMysqlTableSqlString();
	
	static std::string TruncateDuckdbSqlString();
	static std::string TruncateSqliteSqlString();
	static std::string TruncateMysqlSqlString();
	int ToCsvString(char* buff) const;
	int ToDebugString(char* buff) const;
	int GetSqlString(char* buff) const;
};

